var newsTable;
//获取测评项目信息
function getEvaluationProjectList(name) {
    if (typeof newsTable !== 'undefined') {
        newsTable.fnPageChange('first');
        return;
    }
    
    var i = 1;
    newsTable = $("#newsList").DataTable({
        "sAjaxSource": _path + "/evaluationProject/queryByPage",
        "fnServerParams": function (aoData) {
            aoData.push(
                { "name": "name", "value": $("#name").val() },
                { "name": "ageGroup", "value": $("#ageGroup").val() },
                { "name": "fromDate", "value": $("#fromDate").val() },
                { "name": "toDate", "value": $("#toDate").val() },
                { "name": "liveId", "value": $("#liveId").val() }
                
            );
        },
        "sServerMethod": "POST",
        "sAjaxDataProp": "dataList",
        "fnCreatedRow": function () {
            i++;
        },
        "fnPreDrawCallback": function () {
            i = 1;
        },
        "aoColumns": [
            { "sTitle": "序号", "sWidth": "2%",
                "mData": function () {
                    return i;
                }
            },
            { "sTitle": "名称", "sWidth": "10%" ,"mData": 
	            	function(data){
	        		var temps = '<a href="' + _path + '/evaluationProject/edit?id=' + data.id + '&liveId=' + data.liveId + '">'+data.name+'</a>';
	        		return temps;
	        	}
	        },
            { "sTitle": "直播间", "mData": "live.name", "sWidth": "10%" },
            { "sTitle": "创建时间", "mData": "insertTime", "sWidth": "10%" },
            { "sTitle": "操作", "sWidth": "10%",
                "mData": function (data) {
                		var status = '<a href="' + _path + '/evaluationProject/edit?id=' + data.id + '&liveId=' + data.liveId + '" class="btn default btn-xs purple"><i class="fa fa-edit" title="编辑"></i></a>';
                        status += '&nbsp;<a href="' + _path + '/examQuestions/list?projectId=' + data.id + '&liveId=' + data.liveId + '"  class="btn default btn-xs green">题目项</a>';
                        status += '&nbsp;<a href="javascript:inquiry('+data.id+')"  class="btn default btn-xs red"><i class="fa fa-trash-o" title="删除"></i></a>';
                        return status;
                }
            }
        ]
    });
}

function inquiry(id){
	layer.confirm('您确定要删除吗？', {
		  btn: ['确定','取消'] //按钮
		}, function(){
			layer.closeAll('dialog');
			$.ajax({
				url : _path + "/evaluationProject/del/" + id,
				type : "get",
				dataType : "json",
				async : false,
				error : function(request) {
					alert("连接错误！");
				},
				success : function(data) {
					  if(data.msg=='成功'){
						  layer.close
						  App.bubble(200, "删除成功");
						  getEvaluationProjectList();
					  }else{
						  App.bubble(200, "删除异常");
					  }
				}
			});
		//	location.href = _path + "/evaluationProject/del/" + id;
		}, function(){
		
		});
}

